package functional;

import org.openqa.selenium.By;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.Keys;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.testng.annotations.Test;

/**
 * Created by viktor.zhurbenko on 11/12/14.
 */
public class JSUsageExample {
    WebDriver driver = new FirefoxDriver();

    @Test
    public void useJSTest()
    {
        driver.get("http://hotline.ua/");
        ((JavascriptExecutor) driver).executeScript("alert('This is your custom JS');");
        ((JavascriptExecutor) driver).executeScript("document.getElementById('searchbox').value ='Htc';");
        driver.findElement(By.id("searchbox")).sendKeys(Keys.RETURN);
    }

    @Test(dependsOnMethods = "useJSTest", alwaysRun = true)
    public void switchOff()
    {
        driver.quit();
    }

}
